<?php include 'settings.php'; ?>
<?php
//detail page that shows all ayas related to a cat in an easy to read form
header('Content-Type: text/plain');

$thiscat=$_GET['category'];

$con=mysqli_connect($host,$dbuserR,$dbpassR,$dbname);


//$con=mysqli_connect("localhost","quran","quran","Quran");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


$qr="Select * from Category where CIndex='".$thiscat."';";
if($thiscat=="all") $qr="Select * from Category where Banned<>1;";
$result=mysqli_query($con,$qr);


while($row = mysqli_fetch_array($result)) 
{
echo "Catagory|".$row['CIndex']."|".$row['Description']."\n";



//$qr="Select quran_text.sura,quran_text.aya,quran_text.text,suranames.name  from suranames,CategoryAya,quran_text where CategoryAya.Banned=0 and quran_text.sura=suranames.number and  quran_text.index=CategoryAya.AyaIndex and CategoryAya.CategoryIndex='".$thiscat."' order by quran_text.index";
//$qr="Select quran_text.sura,quran_text.aya,quran_text.text as text from CategoryAya,quran_text where quran_text.index=CategoryAya.AyaIndex and CategoryAya.CategoryIndex='".$thiscat."' ";
//echo $qr;
$qr="Select * from CategoryAya where Banned<>1 and CategoryIndex='".$row['CIndex']."';";
$result2=mysqli_query($con,$qr);


while($row1 = mysqli_fetch_array($result2)) 
{

//echo ("<a href='category.php?".$row['CIndex']."'>");
//echo $row['Description']." (".$row['countrow'].")<br>\n</a>";
//if ($lastsura<>$row['sura'] and $lastsura<>0) echo "<br>=========================================<br>";
//if ($lastsura<>$row['sura'] ) echo "<br>".$row['name']."<br>";
//
//if ($lastsura==$row['sura'] and $lastaya<>0 and $row['aya']>$lastaya+1) echo "<br><br>";
echo "CategoryAya|".$row1['CategoryIndex']."|".$row1['AyaIndex']."|".$row1['Sura']."|".$row1['Aya']."\n";

// "CategoryAya|".$row1['CategoryIndex']."|".$row1['AyaIndex']."|".$row1['Sura']."|".$row1['Aya']."\n";



}


}















?> 


